package com.team.sion.mapper;

import com.team.sion.pojo.Comment;
import com.team.sion.pojo.CommentExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CommentMapper {
    long countByExample(CommentExample example);

    int deleteByExample(CommentExample example);

    @Delete({
        "delete from comment",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into comment (id, user_id, ",
        "song_id, songList_id, ",
        "content, createTime, ",
        "type, up, father_id, ",
        "to_user_id)",
        "values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{songId,jdbcType=INTEGER}, #{songlistId,jdbcType=INTEGER}, ",
        "#{content,jdbcType=VARCHAR}, #{createtime,jdbcType=DATE}, ",
        "#{type,jdbcType=VARCHAR}, #{up,jdbcType=INTEGER}, #{fatherId,jdbcType=INTEGER}, ",
        "#{toUserId,jdbcType=INTEGER})"
    })
    int insert(Comment row);

    int insertSelective(Comment row);

    List<Comment> selectByExample(CommentExample example);

    @Select({
        "select",
        "id, user_id, song_id, songList_id, content, createTime, type, up, father_id, ",
        "to_user_id",
        "from comment",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.team.sion.mapper.CommentMapper.BaseResultMap")
    Comment selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("row") Comment row, @Param("example") CommentExample example);

    int updateByExample(@Param("row") Comment row, @Param("example") CommentExample example);

    int updateByPrimaryKeySelective(Comment row);

    @Update({
        "update comment",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "song_id = #{songId,jdbcType=INTEGER},",
          "songList_id = #{songlistId,jdbcType=INTEGER},",
          "content = #{content,jdbcType=VARCHAR},",
          "createTime = #{createtime,jdbcType=DATE},",
          "type = #{type,jdbcType=VARCHAR},",
          "up = #{up,jdbcType=INTEGER},",
          "father_id = #{fatherId,jdbcType=INTEGER},",
          "to_user_id = #{toUserId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Comment row);
}